package com.icxcc.generator.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.icxcc.common.util.R;
import com.icxcc.generator.service.GeneratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("generatorApi")
public class generatorApi {
    @Autowired
    private GeneratorService generatorService;
    @Autowired
    UserInfoRestTemplateFactory userInfoRestTemplateFactory;
    @GetMapping("page")
    public Page page(@RequestParam Map<String, Object> param){

        return generatorService.page(param);
    }

    @GetMapping("user")
    public R user(){
        generatorService.getInfo();
        return R.OK(userInfoRestTemplateFactory.getUserInfoRestTemplate().getOAuth2ClientContext().getAccessToken());
    }
}
